//查询发票具体信息
select 
		GETDATE() newdata,	//开票日期
		s.f_user_name,		//用户姓名
		s.f_userinfo_id,		//用户编号
		isnull(u.f_taxpayer_id,'') f_taxpayer_id,	//纳税人识别号
		s.f_user_id,			//表编号
		s.f_address,			//用户地址
		s.f_payment,			//付款方式
		case when f_preamount=0 then '预收'+s.f_gasproperties else s.f_gasproperties end types,	//品名及规格
		s.f_operator,			//操作员
		isnull(s.f_surplus_gas,0) f_surplus_gas,		//本期剩余气量
		isnull(s.f_haircut_gas,0) f_haircut_gas,		//本期扣减气量
		s.f_balance f_balance,			//本期结余	
		s.f_curbalance  f_curbalance,		//上期结余
		s.f_tablebase f_tablebase,		//本期指数
		s.f_last_tablebase f_last_tablebase,	//上期指数
		case when f_preamount=0 then 0 else s.f_preamount-s.f_balance+f_delaypay end as f_preamount,//应交金额
		s.f_pregas,							//用气量
		s.f_collection,					//实收款
		s.f_delaypay,						//滞纳金
		[dbo].[f_num_chn](s.f_collection) daxie, 		//大写实收款 
		isnull(
		        (
		         select (case when convert(varchar(6),min(f_hand_date),112)=convert(varchar(6),max(f_hand_date),112) 
		         then convert(varchar(6),min(f_hand_date),112) else  
		         convert(varchar(6),min(f_hand_date),112)+'-'+convert(varchar(6),max(f_hand_date),112) end)
                 from t_handplan 
                 where f_sell_id=s.id
                 ),''
               ) mindate
  from t_sellinggas s,t_userinfo u
  where s.f_userinfo_id=u.f_userinfo_id and s.id in ('{id}') 
